import com.mysql.cj.xdevapi.Session;
import com.pojo.Employee;
import com.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

public class EmployeeTest {
    private boolean employee;

    @Test
    public void findEmployee() {
        SqlSession session = MyBatisUtils.getSession();
        System.out.println(employee);
        session.commit();
        session.close();
    }
    @Test
    public void addEmployeeTest() {
        SqlSession Session = MyBatisUtils.getSession();
        Employee employee=new Employee();
        employee.setName("王八");
        employee.setAge(18);
        employee.setPosition("员工");
        int rows =Session.insert ("com.mapper.EmployeeMapper.insert",employee);
        System.out.println(rows);
        Session.commit();
        Session.close();
    }
    @Test
    public void updateEmployeeTest() {
        SqlSession Session = MyBatisUtils.getSession();
        Employee employee=new Employee();
        employee.setId(5);
        employee.setName("周其");
        employee.setAge(20);
        employee.setPosition("员工");
        int rows =Session.update("com.mapper.EmployeeMapper.updateByPrimaryKeySelective",employee);
        System.out.println(rows);
        Session.commit();
        Session.close();
    }
    @Test
    public void deleteEmployeeTest() {
        SqlSession Session = MyBatisUtils.getSession();
        int rows =Session.delete("com.mapper.EmployeeMapper.deleteByPrimaryKey",5L);
        System.out.println(rows);
        Session.commit();
        Session.close();
    }
}
